#pragma once
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

class Util
{
public:
    // 切割函数
    //"1 + 2"
    static bool StringSplit(const std::string &str, const std::string &sep, std::vector<std::string> *result)
    {
        int start = 0;
        size_t pos = str.find(sep);
        while (pos != std::string::npos)
        {
            result->push_back(str.substr(start, pos - start));
            start = pos + sep.size();
            pos = str.find(sep,pos+1);
        }
        if (start < str.size())
            result->push_back(str.substr(start, str.size() - start)); // 防止漏掉最后一个数据
        return true;
    }
    static int ToInt(const std::string str)
    {
        return atoi(str.c_str());
    }
};